// This file is part of Indico.
// Copyright (C) 2002 - 2025 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.

@use 'base' as *;

$indico-theme-color: #1a63a0;
$header-bg-color: $indico-theme-color !default;
$header-icon-color: $light-gray !default;
$header-text-color: $light-gray !default;
$tt-primary-color: $indico-theme-color !default;
$tt-secondary-color: #05b3b3 !default;
$tt-secondary-pastel: #a8dede !default;
$tt-nested-time-color: $light-black !default;
$tt-additional-text-color: $light-black !default;
$selected-color: $indico-blue !default;

@mixin header-logo($image, $position: 15px, $padding-left: 150px, $scale: none) {
  div.event-header {
    background: $header-bg-color url($image) left top no-repeat;
    background-position: $position;
    background-size: $scale;
    padding-left: $padding-left;
  }
}

@mixin drop-shadow {
  box-shadow: 0 2px 10px 1px rgba(50, 50, 50, 0.4);
}

@mixin ribbon($color) {
  @include transition(background-color 0.5s linear);
  border-radius: 0 2px 2px 0;
  $darkened-color: darken($color, 10%);

  background-color: $color;

  &::before {
    content: ' ';
    position: absolute;
    width: 0;
    height: 0;
    left: 0;
    top: 100%;
    border-width: 5px 5px;
    border-style: solid;
    border-color: $darkened-color $darkened-color transparent transparent;
  }
}

body {
  background: #424242;
}

.contrib-description {
  &.plain {
    white-space: pre-line;
  }
}

.item-location {
  @include ellipsis();

  border-radius: 0.2em;
  color: $tt-secondary-color;
  font-size: 1em;
  float: right;
  max-width: 200px;
  margin: 0.5rem 0.7em 0 0;

  &::before {
    color: $tt-secondary-color;
    margin-right: 0.2em;
    vertical-align: middle;
  }

  &.header-data {
    padding: 0;
  }
}

@mixin highlighted-data {
  display: inline-block;
  padding: 0 0.25em 0 0.25em;
  line-height: 1.5rem;
  background-color: $tt-primary-color;
  color: $light-gray;
}

@mixin highlighted-header-data {
  @include highlighted-data();
  @include default-border-radius();
  color: $header-text-color !important;
  background-color: lighten($header-bg-color, 5%);
}

.event-time-data {
  time {
    @include highlighted-header-data();
  }

  .date {
    color: $gray;
  }

  .timezone {
    font-size: 0.8em;
  }
}

.header-data {
  &::before {
    color: $header-icon-color;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    margin-right: 0.4em;
    vertical-align: middle;
  }

  color: $light-gray;
  background-color: transparent;
  display: flex;
  align-items: center;
}

.event-location {
  .text {
    @include highlighted-header-data();
  }

  .icon-location {
    vertical-align: middle;
  }
}

.event-location,
.event-chairs,
.event-date {
  @extend .flexrow;

  &.event-location,
  &.event-chairs {
    margin-top: 0.5em;
  }
}

.timetable-contrib {
  .timetable-title {
    margin-right: 0.2em;
    color: $tt-primary-color;
  }
}

.speaker-list,
.chairperson-list,
.convener-list {
  margin: 0.1em 55px 0 0;

  .label {
    font-weight: bold;
  }

  .affiliation {
    font-size: 0.8em;
    opacity: 0.7;
  }
}

.chairperson-list .author {
  @include highlighted-header-data();
  margin-bottom: 2px;
}

.speaker-list,
.convener-list {
  color: $tt-additional-text-color;
}

.details .address {
  color: #aaa;
  font-size: 12px;
  text-shadow: none;
}

div.event-header {
  border-top-left-radius: $default-border-radius;
  border-top-right-radius: $default-border-radius;

  background: $header-bg-color;
  color: $header-text-color;
  font-size: 12pt;
  position: relative;

  min-height: 125px;
  margin: 0;
  padding: 10px 30px 10px;

  .event-title {
    display: flex;
    justify-content: space-between;
    gap: 0.5em;
    margin-bottom: 10px;

    h1 {
      font-size: 20pt;
      color: $header-text-color;
      font-weight: normal;
      margin-top: 10px;
    }

    .event-actions {
      display: flex;

      @media screen {
        // XXX somehow this breaks printing in chrome (23k pages)
        gap: 0.2em;
      }
      margin-top: 10px;
    }
  }

  &.round-bottom-corners {
    border-bottom-left-radius: $default-border-radius;
    border-bottom-right-radius: $default-border-radius;
  }
}

.event-header {
  @include font-family-title-light();

  .event-label {
    margin-left: 1em !important;
    text-transform: uppercase;
    vertical-align: 50%;
  }
}

.meeting-timetable,
.meeting-sub-timetable {
  list-style-type: none;
  padding: 0;
}

.item-description {
  &.session-description,
  &.break-description,
  &.contrib-description,
  &.subcontrib-description {
    padding: 0.5em 0;
  }

  .event-description {
    color: $black;
  }

  ul {
    margin-bottom: 0.5em;
  }

  ul,
  ol {
    margin-left: 3em;
  }

  :is(ul, ol) :is(ul, ol) {
    margin-left: 1.2em;
  }

  @include font-family-modern-body();
  color: $light-black;
}

// Meeting Timetable-specific

ul.day-list {
  list-style-type: none;
  padding-left: 0;
  margin-left: 0;
  margin-top: 10px;
}

.day-header {
  margin-top: 25px;
  position: relative;
  text-align: center;

  .day-title {
    display: inline-block;
    font-variant: small-caps;
    font-size: 1.7em;
    color: $light-gray;
    padding: 0.5em;
  }

  a.js-go-to-day {
    display: inline-block;
    color: $gray;
    font-size: 1.4em;
    position: absolute;
    padding-bottom: 0.5em;
    right: 0;
    bottom: 0;
  }
}

.meeting-timetable {
  @include font-family-modern-body();
  @include default-border-radius();
  @include drop-shadow();

  padding: 1em 1em 0.5em 0;
  background-color: white;

  .toolbar,
  .toolbar .group {
    margin-bottom: 0;
    padding: 0;
  }

  .timetable-item {
    display: flex;

    &:not(:first-child) {
      margin-top: 1em;
    }

    .timetable-duration {
      margin: 0.5rem 0.7em 0 0;
      min-width: 4em;
      text-align: right;
      color: $dark-gray;

      &::before {
        color: $dark-gray;
        margin-right: 0.2em;
      }
    }
  }
}

.timetable-item-body {
  flex: auto;
  padding-bottom: 0.5rem;
  overflow: hidden;

  /* Without the following IE11 doesn't correctly compute the width of the element. */
  width: 100%;

  &:not(:hover)
    > .timetable-item-header
    .timetable-item-actions
    .manage-button:not(.selected)
    .i-button {
    background-color: #fff;
    border-color: $gray !important;
  }

  &:not(:first-child) {
    margin-left: 1em;
  }

  .timetable-item-header {
    flex: auto;

    .timetable-title {
      font-weight: bold;
      font-size: 1.1em;
      padding-top: 0.5rem;
      @include font-family-title();
      flex: auto;
      line-height: 1rem;

      &.nested {
        color: $tt-primary-color;
      }
    }

    .timetable-item-actions {
      flex-shrink: 0;
      padding-top: 0.25rem;
      max-height: 2.2em;

      .manage-button {
        .i-button {
          @include transition(background-color 0.25s linear);
        }
      }
    }
  }

  .material-list {
    padding-top: 0.4em;
  }
}

.event-manage-button {
  font-size: 10pt;

  button.open {
    border-bottom-left-radius: 0;
  }

  .i-dropdown {
    border-top-left-radius: 0;
  }
}

.event-privacy-info-button {
  @include font-family-body();
  font-size: 12pt;

  .privacy-dropdown {
    display: inline-block;
    position: relative;
    outline: none;

    .menu {
      display: none;
      position: absolute;
      z-index: 1;
      top: 1.8em;
      right: 0.2em;
      min-width: 10em;
      border-radius: 2px;
      background-color: $light-gray;
      box-shadow: 0 2px 10px 1px rgba(50, 50, 50, 0.4);
      padding-top: 0.2em;

      .item,
      .header {
        display: block;
        padding: 0 0.5em 0.4em;
        font-size: 0.9em;

        &:not(a) {
          color: $black;
        }

        &.header {
          padding-bottom: 0.2em;
          font-weight: bold;
          text-transform: uppercase;
          font-size: 0.8em;
        }
      }

      .divider {
        border-top: 1px dotted $dark-gray;
        height: 0;
        margin-bottom: 0.2em;
      }
    }

    &:focus-within .menu {
      display: block;
    }
  }
}

.meeting-sub-timetable {
  margin-top: 1em;
}

.subcontrib-list {
  list-style-type: none;
  padding: 0;

  .timetable-item.timetable-subcontrib {
    border-left: 2px dotted $gray;
    padding-left: 1em;

    .timetable-title {
      font-weight: normal;
    }

    .speaker-list {
      padding-top: 0.5em;
    }
  }
}

.timetable-time {
  color: $tt-primary-color !important;
  flex-shrink: 0;
  line-height: 2rem;

  &.top-level {
    .start-time {
      background-color: $tt-primary-color;
      font-weight: bold;
      box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, 0.1);
      margin-left: -10px;
      padding: 0 10px 0 20px;
      position: relative;
      @include ribbon($tt-primary-color);
    }
  }

  &.nested {
    @include transition(border-color 0.5s linear);
    margin-right: 0.5em;
    border-right: 3px solid $tt-nested-time-color;

    .start-time {
      padding: 0 5px 0 10px;
      background-color: $tt-nested-time-color;
    }
  }

  &.break {
    color: $tt-secondary-color !important;
    border-color: $tt-secondary-color;

    .end-time {
      color: $tt-secondary-color !important;
    }

    &.top-level .start-time {
      @include ribbon($tt-secondary-color);
    }

    &.nested .start-time {
      background-color: $tt-secondary-color;
    }
  }

  .start-time {
    @include highlighted-data();
    border-radius: 2px 0 0 2px;
    @include transition(background-color 0.5s linear);
    color: $light-gray !important;
  }

  .end-time {
    color: $tt-primary-color;
  }
}

.timetable-item.timetable-break {
  .timetable-item-body {
    .timetable-title {
      text-align: center;
      color: $tt-secondary-color !important;
    }

    .timetable-duration,
    .timetable-duration::before {
      color: $tt-secondary-color !important;
    }

    .timetable-item-header {
      background-color: $light-gray;
      padding-bottom: 0.5em;
    }
  }

  .location-info {
    margin-left: 1em;
  }
}

.event-sub-header {
  border-radius: 0 0 2px 2px;
  @include drop-shadow();
  @include font-family-title-light();

  background: white;
  font-size: 12px;
  color: black;
  margin: 0;
  padding: 3px 3px;
}

.note-area-wrapper .note-area {
  @include font-family-modern-body();
  margin-top: 10px;
}

// Lectures

.event-header-lecture {
  & > h1 {
    margin-top: 1em;
  }

  & > h2 {
    font-size: 1.1em;
    color: $gray;
  }

  .lecture-category {
    color: $tt-secondary-pastel;
  }
}

a.lecture-series-link {
  display: inline-block;
  padding: 0.2em 0.5em;
  background: $header-bg-color;
  color: $light-gray !important;
  margin-right: 0.1em;
}

.timetable-item:target {
  .timetable-time {
    border-color: $selected-color;

    .start-time {
      background-color: $selected-color;
    }
  }

  .timetable-title {
    color: $selected-color !important;
  }

  &.timetable-block > .timetable-time .start-time {
    @include ribbon($selected-color);
  }

  &.timetable-subcontrib,
  .timetable-subcontrib {
    border-color: $selected-color;
  }
}

.days-dropdown {
  li {
    white-space: nowrap;
  }
}

.agenda-placeholder {
  @include default-border-radius();
  background-color: white;
  margin-top: 10px;
  flex-grow: 1;
  color: $gray;
  text-align: center;
  height: 250px;

  .placeholder-icon {
    font-size: 5em;
  }

  .agenda-placeholder-content {
    margin: auto;
  }

  .placeholder-text {
    font-size: 1.5em;
    font-weight: bold;
  }

  a {
    color: $link;
  }

  a:hover {
    text-decoration: underline;
  }
}

div.event-details {
  font-size: 1.1em;

  .event-details-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.5em;
  }

  .event-details-label {
    width: 120px;
    text-align: right;
    font-weight: bold;
    margin-right: 1em;

    &.align-top {
      align-self: flex-start;
    }
  }

  .event-details-content {
    flex: 1;
  }
}

.attachments-display-container {
  flex-wrap: wrap;

  // needed to nullify the margin of the items in this flexbox
  // for the very first items of each row
  margin-left: -0.2em;
}
